package org.example.mapper;

import org.apache.ibatis.annotations.*;
import org.example.pojo.Food;

import java.util.List;

@Mapper
public interface FoodMapper {

    // 查询所有食物
    @Select("select * from food")
    List<Food> findAll();

    // 根据id查询食物
    @Select("select * from food where id = #{id}")
    Food findById(Long id);

    // 添加食物
    @Insert("INSERT INTO food(food_name, food_price) VALUES(#{foodName}, #{foodPrice})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void addFood(Food food);

    // 删除食物
    @Delete("DELETE FROM food WHERE id = #{id}")
    int deleteById(Long id);

}
